package cn.dlc.com.controller;

import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author deng
 * @date 2021/6/25 9:26
 **/

@RestController
@RequestMapping("order")
public class OrderController {

    // 没有权限，可以直接访问
    @GetMapping("/findAll")
    public String findAll(){

        System.out.println("world hello");
        System.out.println("world hello");
        System.out.println("world hello");

        return "order-list";
    }

    //
    @GetMapping("/findAll/permission")
    @PreAuthorize("hasPermission('order/findAll/permission',null)")
    public String findAllPermission(){

        System.out.println("world findAllPermission");
        System.out.println("world findAllPermission");
        System.out.println("world findAllPermission");

        return "findAllPermission-list";
    }

    // 前面是路径，后面是增删查改
    @GetMapping("/findAll/permission2")
    @PreAuthorize("hasPermission('order/findAll/permission2','')")
    public String findAllPermission2(){

        System.out.println("world findAllPermission2");
        System.out.println("world findAllPermission2");
        System.out.println("world findAllPermission2");

        return "findAllPermission-list";
    }
}
